package zeebe.head;

import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.response.WorkflowInstanceEvent;
import io.zeebe.protocol.record.*;
import io.zeebe.protocol.record.intent.WorkflowInstanceIntent;
import io.zeebe.protocol.record.value.WorkflowInstanceRecordValue;

import java.util.List;
import java.util.function.Predicate;

public class HeadStart {
    public static void main(String[] args) {
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("启动工作流");
        String processId = "head";

        WorkflowInstanceEvent wfInstance = client.newCreateInstanceCommand()
                .bpmnProcessId(processId)
                .latestVersion()
                .send()
                .join();
    }

    private static Predicate<Record<WorkflowInstanceRecordValue>> intent(List<WorkflowInstanceIntent> intents) {
        return (record) -> intents.contains(record.getIntent());
    }
}
